<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<link rel="stylesheet" type="text/css" href="css/global.css" />
		<link rel="stylesheet" type="text/css" href="css/muibar.css" />
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		
	</head>
	<body>
		        <div class="mainbody">
		    <div class="login w894">
		        <div class="login_bg fl"><img src="http://43.243.128.175//theme/jomoo/zh_cn/shop/images/pic/login_left_bg.jpg" width="490" height="490" /></div>
		        <div class="login_box fr">
		            <!--登录内容区 start-->
		                            <!--注册内容区 start-->
		                <h2>欢迎注册</h2>
		                <form name="" action="/" method="post" id="regform" >
		                    <ul>
		                        <li><input id="tel" type="text" placeholder="账号/手机" class="input w310">
		                            <div id="reg_tel_tips" class="Validform_checktip"></div>
		                        </li>
		                        <li><input id="reg_password" type="password" placeholder="密码" class="input w310 password">
		                            <div id="reg_pw_tips" class="Validform_checktip"></div>
		                        </li>
		                        <li><input id="reg_repassword" type="password"  placeholder="再次输入密码" class="input w310 password">
		                            <div id="reg_repw_tips" class="Validform_checktip"></div>
		                        </li>
		                        <li>
		                            <input type="text" id="yan" placeholder="验证码" class="input w185">
		                            <a href="javascript:;" onclick="javascript:changeImg('greph2', 'reg');" class="code">
		                                <img id="greph2"   src="http://shop.erke.com/?app_act=secret/reg_create_verify_graph" width="125" height="38" ></a>
		                            <div id="reg_yan_tips" class="Validform_checktip"></div>
		                        </li>
		                        <li>
		                            <input type="text" id="note_yan" placeholder="手机验证码" class="input w185">

		                            <input id="get_captcha" type="button" tabindex="4" value="发送验证码" onclick="gcode()" class="codes " />
		                            <div id="note_yan_tips" class="Validform_checktip"></div>
		
		                        </li>
		                    </ul>
		                    <div class="btn-box" style="padding-top: 0px;">
		                        <div class="col clearfix"><input name="" class="submit2 fl" type="button" value="注 册" onclick="reg();"></div>
		                        <div class="exist"><a href="http://shop.erke.com/?app_act=member/login_reg&type=login">我已有账号,现在登录</a></div>
		                    </div>
		                </form>
		                
		            <!--end 注册内容区-->
		        </div>
		        <div class="cb"></div>
		    </div>
		</div>

	</body>
</html>
<script src="jQuery.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
	$("header").load('header.html',function(){});

	//注册
	 function reg() {
	        var reg_tel = $.trim($('#tel').val());
	        var reg_password = $.trim($('#reg_password').val());
	        var reg_repassword = $.trim($('#reg_repassword').val());
	        var verify = $.trim($('#yan').val());
	        var reg_yan = $.trim($('#note_yan').val());
	
	        if (reg_tel == "") {
	            $('#reg_tel_tips').addClass('Validform_wrong');
	            $('#reg_tel_tips').html('请输入您要注册的手机号噢！');
	            return false;
	        } else if (!(/^[0-9]{11}$/.test(reg_tel))) {
	            $('#reg_tel_tips').addClass('Validform_wrong');
	            $('#reg_tel_tips').html('请输入正确的手机号噢！');
	            return false;
	        } else {
	            $('#reg_tel_tips').html('');
	            $('#reg_tel_tips').removeClass('Validform_wrong');
	        }
	        
	        if (reg_password == "") {
	            $('#reg_pw_tips').addClass('Validform_wrong');
	            $('#reg_pw_tips').html('请输入您要注册的登录密码噢！');
	            return false;
	        }
	
	        if (reg_password != reg_repassword) {
	            $('#reg_repw_tips').addClass('Validform_wrong');
	            $('#reg_repw_tips').html('两次输入的密码不一致噢！');
	            return false;
	        } else {
	            $('#reg_repw_tips').html('');
	            $('#reg_repw_tips').removeClass('Validform_wrong');
	        }
	        if (verify == "") {
	            $('#reg_yan_tips').addClass('Validform_wrong');
	            $('#reg_yan_tips').html('请输入验证码噢！');
	            return false;
	        } else {
	            $('#reg_yan_tips').html('');
	            $('#reg_yan_tips').removeClass('Validform_wrong');
	        }
	
	       if (reg_yan == "") {
	           $('#note_yan_tips').addClass('Validform_wrong');
	            $('#note_yan_tips').html('请输入验证码噢！');
	           return false;
	       } else {
	            $('#note_yan_tips').html('');
	            $('#note_yan_tips').removeClass('Validform_wrong');
	       }
	
	        var parameter = new Object();
	        parameter['tel'] = reg_tel;
	        parameter['password'] = reg_password;
	        parameter['yan'] = reg_yan;
	        parameter['verify'] = verify;
	        //parameter['use_invite_code'] = $("#use_invite_code").val();
	        var url = site_url + "member/register";
	        var params = parameter;
	        Ajax.call(url, params,
	                function(s) {
	                    if (s.status == 1) {
	                        window.location.href = "http://shop.erke.com/?app_act=member/reg_success";
	                    } else {
	                        switch (s.status) {
	                            case -1:
	                                $('#reg_tel_tips').addClass('Validform_wrong');
	                                $('#reg_tel_tips').html(s.message);
	                                break;
	                            case -2:
	                                $('#reg_pw_tips').addClass('Validform_wrong');
	                                $('#reg_pw_tips').html(s.message);
	                                break;
	                            case -3:
	                                $('#reg_yan_tips').addClass('Validform_wrong');
	                                $('#reg_yan_tips').html(s.message);
	                                break;
	                            case -4:
	                                $('#note_yan_tips').addClass('Validform_wrong');
	                                $('#note_yan_tips').html(s.message);
	                                break;
	                        }
	                    }
	                }, 'POST', 'json');
	    }
	
	    var n = 60;
	    var test;
	    function gcode(){
	        var reg_tel = $.trim($('#tel').val());
	        var verify = $.trim($('#yan').val());
	        if (reg_tel == "") {
	            $('#reg_tel_tips').addClass('Validform_wrong');
	            $('#reg_tel_tips').html('请输入您要注册的手机号噢！');
	            return false;
	        } else if (!(/^[0-9]{11}$/.test(reg_tel))) {
	            $('#reg_tel_tips').addClass('Validform_wrong');
	            $('#reg_tel_tips').html('请输入正确的手机号噢！');
	            return false;
	        } else {
	            $('#reg_tel_tips').html('');
	            $('#reg_tel_tips').removeClass('Validform_wrong');
	        }
	
	        if (verify == "") {
	             $('#note_yan_tips').addClass('Validform_wrong');
	            $('#note_yan_tips').html('请输入验证码噢！');
	            return false;
	        } else {
	            $('#note_yan_tips').html('');
	            $('#note_yan_tips').removeClass('Validform_wrong');
	        }
	        var url = site_url + "member/get_verification_code";
	        var params = "tel=" + reg_tel + "&type=reg" + "&verify=" + verify;
	        Ajax.call(url, params,
	            function(s) {
	                s = eval(s);
	                if (s.status == 1) {
	                    layer.msg(s.message, { icon: 1 });
	                    $('#get_captcha').attr({'disabled':"disabled"});
	                    test = setInterval(function(){showtime();},1000);
	                } else {
	                    layer.msg(s.message, { icon: 2 });
	                }
	            }, 'POST', 'json');
	
	    }
	     
	     function showtime(){
	         if((--n)>=0){
	            $('#get_captcha').attr({value: n+"s后可重发"});
	            if(n == 0){
	                $('#get_captcha').val("发送验证码");
	                $('#get_captcha').attr({'disabled':false});
	                clearInterval(test);
	                n=60;
	            }
	         }
	     }
</script>